package com.office.system.service.impl;

import java.util.List;
import java.util.Map;
import java.util.Date;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.office.system.mapper.FinanceIncomeMapper;
import com.office.system.domain.FinanceIncome;
import com.office.system.service.IFinanceIncomeService;
import com.office.common.utils.uuid.Seq;
import java.math.BigDecimal;

/**
 * 收入记录Service业务层处理
 * 
 * @author 数字牧马人
 */
@Service
public class FinanceIncomeServiceImpl implements IFinanceIncomeService 
{
    @Autowired
    private FinanceIncomeMapper financeIncomeMapper;

    /**
     * 查询收入记录
     * 
     * @param incomeId 收入记录主键
     * @return 收入记录
     */
    @Override
    public FinanceIncome selectFinanceIncomeByIncomeId(Long incomeId)
    {
        return financeIncomeMapper.selectFinanceIncomeByIncomeId(incomeId);
    }

    /**
     * 查询收入记录列表
     * 
     * @param financeIncome 收入记录
     * @return 收入记录
     */
    @Override
    public List<FinanceIncome> selectFinanceIncomeList(FinanceIncome financeIncome)
    {
        return financeIncomeMapper.selectFinanceIncomeList(financeIncome);
    }

    /**
     * 新增收入记录
     * 
     * @param financeIncome 收入记录
     * @return 结果
     */
    @Override
    public int insertFinanceIncome(FinanceIncome financeIncome)
    {
        // 生成收入编号
        if (financeIncome.getIncomeNo() == null || financeIncome.getIncomeNo().isEmpty()) {
            financeIncome.setIncomeNo("INC" + Seq.getId());
        }
        // 设置创建时间
        if (financeIncome.getCreateTime() == null) {
            financeIncome.setCreateTime(new Date());
        }
        return financeIncomeMapper.insertFinanceIncome(financeIncome);
    }

    /**
     * 修改收入记录
     * 
     * @param financeIncome 收入记录
     * @return 结果
     */
    @Override
    public int updateFinanceIncome(FinanceIncome financeIncome)
    {
        return financeIncomeMapper.updateFinanceIncome(financeIncome);
    }

    /**
     * 批量删除收入记录
     * 
     * @param incomeIds 需要删除的收入记录主键
     * @return 结果
     */
    @Override
    public int deleteFinanceIncomeByIncomeIds(Long[] incomeIds)
    {
        return financeIncomeMapper.deleteFinanceIncomeByIncomeIds(incomeIds);
    }

    /**
     * 删除收入记录信息
     * 
     * @param incomeId 收入记录主键
     * @return 结果
     */
    @Override
    public int deleteFinanceIncomeByIncomeId(Long incomeId)
    {
        return financeIncomeMapper.deleteFinanceIncomeByIncomeId(incomeId);
    }

    /**
     * 统计收入金额
     * 
     * @param financeIncome 查询条件
     * @return 收入金额
     */
    @Override
    public BigDecimal selectIncomeAmount(FinanceIncome financeIncome)
    {
        return financeIncomeMapper.selectIncomeAmount(financeIncome);
    }

    /**
     * 按分类统计收入
     * 
     * @param financeIncome 查询条件
     * @return 分类统计结果
     */
    @Override
    public List<Map<String, Object>> selectIncomeByCategory(FinanceIncome financeIncome)
    {
        return financeIncomeMapper.selectIncomeByCategory(financeIncome);
    }
} 